﻿<local:BaseSourceContentFrame x:Class="InfFront.InfoViews.WPF.CommandListFrame"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:InfFront.InfoViews.WPF"
    xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
    Height="Auto" Width="Auto" MinWidth="300" MinHeight="300"
    >

    <UserControl.Resources>
        <local:IconedObjectToNormal24x24ImageConverter x:Key="getNormal24x24Image"/>
    
        <Style x:Key="LinkButton" TargetType="{x:Type Button}">
            <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="IsEnabled" Value="{Binding Path=IsEnabled}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <WrapPanel x:Name="Panel">
                            <WrapPanel.Background>
                                <SolidColorBrush Color="{Binding Path=VisualSettings.CommandButtonColor, FallbackValue=Azure}" />
                            </WrapPanel.Background>
                            <Image Width="24" Height="24" Margin="4" Source="{Binding Converter={StaticResource getNormal24x24Image}}"
                                   VerticalAlignment="Center"/>
                            <WrapPanel Orientation="Vertical" Margin="4,0,40,0" VerticalAlignment="Center">
                                <TextBlock Text="{Binding Path=Title}" FontWeight="Bold" />
                                <TextBlock Text="{Binding Path=Comment}" />
                            </WrapPanel>
                        </WrapPanel>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="Panel" Property="Background">
                                    <Setter.Value>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                            <GradientStop Offset="0" Color="{Binding Path=VisualSettings.CommandButtonColor, FallbackValue=Azure}"/>
                                            <GradientStop Offset="1" Color="{Binding Path=VisualSettings.PrimaryBackgroundColor, FallbackValue=Lavender}"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <!--<Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="Panel" Property="Fill">
                                    <Setter.Value>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>-->
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    
    </UserControl.Resources>

    <WrapPanel Name="pnlCommands" Margin="16,16,0,0">
        <ItemsControl x:Name="commandsControlList" VerticalContentAlignment="Center">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Button Focusable="False" Margin="6" 
                            Click="CommandButton_Click" VerticalAlignment="Center"
                            IsEnabled="{Binding Path=IsEnabled}"
                            ToolTip="{Binding Path=Comment}" BorderThickness="0">
                        <Button.Background>
                            <SolidColorBrush Color="{Binding Path=VisualSettings.CommandButtonColor, FallbackValue=Azure}" />
                        </Button.Background>
                        <WrapPanel>
                            <Image Width="24" Height="24" Source="{Binding Converter={StaticResource getNormal24x24Image}}"/>
                            <WrapPanel Orientation="Vertical" Margin="8,0,0,0" VerticalAlignment="Center">
                                <TextBlock Text="{Binding Path=Title}" FontWeight="Bold" />
                                <TextBlock Text="{Binding Path=Comment}" />
                            </WrapPanel>
                        </WrapPanel>
                    </Button>
                    <!--<Button Margin="6" Click="CommandButton_Click" VerticalAlignment="Center"
                            Style="{StaticResource LinkButton}" />-->
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </WrapPanel>
</local:BaseSourceContentFrame>